<?php
include("classes/include.php");
/* post.php : this page shows what insert.php has sent */


//$requeteTexte = new RequeteSQL("UPDATE texte set tex_texte='".$_POST['content']."' where tex_num_text=1 ");   
//$requeteTexte->executeQuery();
//
//header("Location: administrationTexte.php");

if(isset($_POST['saveActu']))
{
	
	$reqSelect = new RequeteSQL("SELECT * FROM texte WHERE tex_type = 'actualite'");
	$reqSelect->executeQuery();
	
	//$ligneText = $reqSelect->fetch();
	
	if($reqSelect->compteLignes() > 0)
	{
		$reqUpdate = new RequeteSQL("UPDATE texte SET tex_texte = '".$_POST['content']."' WHERE tex_type='actualite'");
		$reqUpdate->executeEcriture();
	}
	else
	{
		$reqInsert = new RequeteSQL("INSERT INTO texte VALUES('','".$_POST['content']."','actualite')");
		$reqInsert->executeEcriture();
	}
	
	header("Location: administrationTexte.php");
}
if(isset($_POST['savePres']))
{
	
	$reqSelect = new RequeteSQL("SELECT * FROM texte WHERE tex_type = 'presentation'");
	$reqSelect->executeQuery();
	
	//$ligneText = $reqSelect->fetch();
	
	if($reqSelect->compteLignes() > 0)
	{
		$reqUpdate = new RequeteSQL("UPDATE texte SET tex_texte = '".$_POST['content']."' WHERE tex_type='presentation'");
		$reqUpdate->executeEcriture();
	}
	else
	{
		$reqInsert = new RequeteSQL("INSERT INTO texte VALUES('','".$_POST['content']."','presentation')");
		$reqInsert->executeEcriture();
	}
	
	header("Location: administrationTexte.php");
}
if(isset($_POST['saveCons']))
{
	
	$reqSelect = new RequeteSQL("SELECT * FROM texte WHERE tex_type = 'conseil'");
	$reqSelect->executeQuery();
	
	//$ligneText = $reqSelect->fetch();
	
	if($reqSelect->compteLignes() > 0)
	{
		$reqUpdate = new RequeteSQL("UPDATE texte SET tex_texte = '".$_POST['content']."' WHERE tex_type='conseil'");
		$reqUpdate->executeEcriture();
	}
	else
	{
		$reqInsert = new RequeteSQL("INSERT INTO texte VALUES('','".$_POST['content']."','conseil')");
		$reqInsert->executeEcriture();
	}
	
	header("Location: administrationTexte.php");
}
if(isset($_POST['saveContact']))
{
	
	$reqSelect = new RequeteSQL("SELECT * FROM texte WHERE tex_type = 'contact'");
	$reqSelect->executeQuery();
	
	//$ligneText = $reqSelect->fetch();
	
	if($reqSelect->compteLignes() > 0)
	{
		$reqUpdate = new RequeteSQL("UPDATE texte SET tex_texte = '".$_POST['content']."' WHERE tex_type='contact'");
		$reqUpdate->executeEcriture();
	}
	else
	{
		$reqInsert = new RequeteSQL("INSERT INTO texte VALUES('','".$_POST['content']."','contact')");
		$reqInsert->executeEcriture();
	}
	
	header("Location: administrationTexte.php");
}
if(isset($_POST['saveInfo']))
{
	
	$reqSelect = new RequeteSQL("SELECT * FROM texte WHERE tex_type = 'info'");
	$reqSelect->executeQuery();
	
	//$ligneText = $reqSelect->fetch();
	
	if($reqSelect->compteLignes() > 0)
	{
		$reqUpdate = new RequeteSQL("UPDATE texte SET tex_texte = '".$_POST['content']."' WHERE tex_type='info'");
		$reqUpdate->executeEcriture();
	}
	else
	{
		$reqInsert = new RequeteSQL("INSERT INTO texte VALUES('','".$_POST['content']."','info')");
		$reqInsert->executeEcriture();
	}
	
	header("Location: administrationTexte.php");
}
if(isset($_POST['savePlan']))
{
	
	$reqSelect = new RequeteSQL("SELECT * FROM texte WHERE tex_type = 'plan'");
	$reqSelect->executeQuery();
	
	//$ligneText = $reqSelect->fetch();
	
	if($reqSelect->compteLignes() > 0)
	{
		$reqUpdate = new RequeteSQL("UPDATE texte SET tex_texte = '".$_POST['content']."' WHERE tex_type='plan'");
		$reqUpdate->executeEcriture();
	}
	else
	{
		$reqInsert = new RequeteSQL("INSERT INTO texte VALUES('','".$_POST['content']."','plan')");
		$reqInsert->executeEcriture();
	}
	
	header("Location: administrationTexte.php");
}


?>